JavaScript The Ultimate Beginners Guide Start Coding Today by 2016

JavaScript The Ultimate Beginners Guide Start Coding Today by 2016
Author: 2016
Language: eng
Format: epub

You will be obtaining the same results from Chrome: I have assigned values in Chrome for myString1 because it returns an error that myString1 was not defined.

Notice that you can use the name of your string, but it must be specified in your repeat command. When I used:

res = string.repeat(5);

I obtained a return error because the string was not defined.

See next image:

Let’s try to define the string and see what happens.

Example:

var string = “Love can move mountains.”;

When you execute the command:

var res = string.repeat(5);

The‘Console’will execute it with the expected output–the string is repeated 5 times. See next image: